#pragma once

#include "G4Material.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VUserDetectorConstruction.hh"

class DetectorMessenger;
class G4LogicalVolume;

class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
    /// world phantom 默认尺寸
    DetectorConstruction();
    virtual ~DetectorConstruction();

    G4VPhysicalVolume* Construct();

    void SetNewMaterial(const G4String& m);

    inline G4double GetGeneratorPosZ() const { return _fGeneratorPosZ; };
    inline void SetPhantomZ(G4double val) { _fPhantomZ = val; }
    inline void SetPhantomXY(G4double val) { _fPhantomXY = val; }  //2022.10.18
    inline void SetFactor(G4double val) { _fFactor = val; }        //2022.10.18

    G4double GetPhantomZ() const { return _fPhantomZ; }

    void SetVerbose(G4bool v) { _fVerbose = v; }
    inline G4bool GetVerbose() const { return _fVerbose; }

    void DumpGeometryParameters();

    const G4VPhysicalVolume* GetPhantom() const { return _fPhantom; }
    G4double GetPhantomXY() const { return _fPhantomXY; }

private:
    /// 根据用户输入, 计算 world, phantom 尺寸
    void InitialiseGeometryParameters();

    DetectorConstruction& operator=(const DetectorConstruction& right);
    DetectorConstruction(const DetectorConstruction&);

    G4bool _fVerbose;

    G4double _fWorldXY, _fWorldZ;
    G4double _fPhantomXY, _fPhantomZ;
    G4double _fPhantomShiftZ;
    G4double _fGeneratorPosZ;

    G4LogicalVolume* _fLogicPhantom;
    G4VPhysicalVolume* _fPhantom;

    G4Material* _fWorldMaterial;
    G4Material* _fAbsorberMaterial;

    DetectorMessenger* _fMessenger;

    G4double _fFactor;  //2022.10.18
};
